<?php 
//die('aa');
defined( '_JEXEC' ) or die( 'Restricted access' );
JHTML::_('behavior.modal', 'a.modal');
//print_r(JFactory::getConfig());exit();
$db = JFactory::getDBO();
$query = "SELECT auction_date FROM #__auction_date WHERE id = 1";
$db->setQuery($query);
$auction_date = $db->loadResult();

$query = "SELECT auction_date FROM #__auction_date WHERE id = 2";
$db->setQuery($query);
$status = $db->loadResult();
?>
<script language="javascript">
function saveDate(){
	document.getElementById('save_date').href= 'index.php?option=com_auction&controllers=default&task=saveDate&date='+document.getElementById("auction_date").value;
	document.getElementById("save_date").click();
}
popUp = function(linkPopUp, title){
	myWin = window.open( linkPopUp, title, "menubar=0,location=0,scrollbars=1,height=1000,width=2000" );
}
</script>
Auction date
<?php echo JHTML::_('calendar', $auction_date, 'auction_date', 'auction_date', '%d-%m-%Y', array('class'=>'inputbox', 'size'=>'32',  'maxlength'=>'32', 'onchange'=>'changeDate(this.value)')); ?>&nbsp;&nbsp;&nbsp;<button onclick="saveDate();"><?php echo JText::_( 'Save' ); ?></button><a href="#" id="save_date"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="popUp('../index.php?option=com_ecommerce&view=detail&layout=printlist&tmpl=component','List');"><img src="../images/print_button.png" /></a>
<?php if($status){?>
<h3>The auction is running</h3> <a href="index.php?option=com_auction&controllers=default&task=saveAuctionStatus&status=0"><img src="../images/btn_stop.png" /></a>
<?php } else {?>
<h3>The auction is not running</h3> <a href="index.php?option=com_auction&controllers=default&task=saveAuctionStatus&status=1"><img src="../images/btn_start.png" /></a>
<?php }?>
<div style="margin-bottom:10px;"></div>
<form action="index.php" method="post" name="adminForm">
  <div id="editcell">
    <table class="adminlist">
      <thead>
        <tr>
          <th width="2%"> <input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count( $this->auctions ); ?>);" />
          </th>
          <th width="2%"> <?php echo JText::_( 'ID' ); ?> </th>
          <th width="20%">Product name</th>
          <th width="13%">Image</th>
          <th width="5%">Kat No</th>
          <th width="20%">Description</th>
          <th width="8%">Date</th>
          <th width="8%">Current price</th>
          <th width="8%">Max. Autobid</th>
          <th width="5%">Published</th>
          <th width="5%">Vis mindstepris</th>
          <th width="5%" nowrap="nowrap">Print</th>
        </tr>
      </thead>
      <?php
	$k = 0;
	for ($i=0, $n=count( $this->auctions); $i < $n; $i++)
	{	
		$row = &$this->auctions[$i];
		$checked 	 = JHTML::_('grid.id',   $i, $row->id );
		$link 		 = JRoute::_( 'index.php?option=com_auction&task=edit&cid[]='. $row->id );
		$query = "SELECT id FROM #__auction_auto WHERE auc_id = ".$row->id;
		$db->setQuery($query);
		$isAuto = $db->loadResult();
		?>
      <tr class="<?php echo "row$k"; ?>">
        <td align="center"><?php echo $checked; ?></td>
        <td align="center"><?php echo $row->id; ?></td>
        <td align="center"><a href="<?php echo $link; ?>"><?php echo $row->model; ?></a> </td>
        <td align="center">
		<?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$row->image."&w=100&zc=1' title='".$row->model."' alt='".$row->model ."' />";?>
        </td>
        <td align="center"><?php echo $row->katno; ?></td>
        <td align="center"><?php echo $row->short_description; ?></td>
        <td align="center"><?php echo $row->auction_date; ?></td>
        <td align="center">
		<a class="modal" rel="{handler: 'iframe', size: {x: 500, y: 340}}" href="../index.php?option=com_ecommerce&view=detail&layout=history&tmpl=component&auc_id=<?php echo $row->id;?>"><?php echo $row->currentprice;?> DKK</a></td>
        <td align="center">
		<a class="modal" rel="{handler: 'iframe', size: {x: 500, y: 340}}" href="../index.php?option=com_ecommerce&view=detail&layout=auto&tmpl=component&auc_id=<?php echo $row->id;?>"><?php if($isAuto) echo '<strong><span style="color:#F00">View</span></strong>'; else echo 'View';?></a></td>
        <?php if($row->published){ ?>
        <td width="5%" align="center" ><a href="#unpublish" onClick="return listItemTask('cb<?php echo $i;?>','unpublish')"><img border="0" alt="Published" src="images/tick.png"/></a></td>
        <?php } else { ?>
        <td width="5%" align="center" ><a href="#publish" onClick="return listItemTask('cb<?php echo $i;?>','publish')"><img border="0" alt="Unpublished" src="images/publish_x.png"/></a></td>
        <?php } ?>
        
         <?php if($row->show_status){ ?>
        <td width="5%" align="center" ><a href="#unshow" onClick="return listItemTask('cb<?php echo $i;?>','unshow')"><img border="0" alt="Show" src="images/tick.png"/></a></td>
        <?php } else { ?>
        <td width="5%" align="center" ><a href="#show" onClick="return listItemTask('cb<?php echo $i;?>','show')"><img border="0" alt="Unshow" src="images/publish_x.png"/></a></td>
        <?php } ?>
         <td align="center">
            <a href="javascript:void(0);" onclick="popUp('../index.php?option=com_ecommerce&view=detail&layout=printcar&tmpl=component&id=<?php echo $row->id;?>','Information')"><img src="../images/print.png" /></a>
        </td>
      </tr>
      <?php
		$k = 1 - $k;
	}
	?>
      <tr>
        <td colspan="16"><?php echo $this->page->getListFooter(); ?> </td>
      </tr>
    </table>
  </div>
  <input type="hidden" name="option" value="com_auction" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="boxchecked" value="0" />
</form>
